package com.bwie.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbApprService;
import com.bwie.service.TbBrandService;
import com.bwie.service.TbProdService;
import com.bwie.service.TbUnitService;
import com.bwie.utils.Result;
import com.bwie.vo.AttaVo;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProdPageVo;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.asn1.crmf.PKIPublicationInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:Max
 * @Date: 2024/8/9 19:00
 * @Description
 **/
@RestController
@RequestMapping("/shop/prod")
public class TbProdController {
    @Autowired
    TbProdService tbProdService;

    @Autowired
    TbUnitService tbUnitService;
    @Autowired
    TbBrandService tbBrandService;

    @Autowired
    TbApprService tbApprService;

    /**
     * 分页获取商品列表
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody ProdPageVo prodPageVo) {
        return tbProdService.getProdList(prodPageVo);
    }


    /**
     * 添加商品
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody TbProd tbProd) {
        return tbProdService.addProd(tbProd);
    }

    /**
     * 获取商品类型的树 用于下拉框
     */
    @PostMapping("/getTypeSelectTree")
    public Result getTypeSelectTree() {
        return tbProdService.getTypeSelectTree();
    }

    @ApiOperation("查询所有的单位")
    @PostMapping("/getUnitListAll")
    public Result getUnitListAll() {
        return tbUnitService.getUnitListAll();
    }

    @ApiOperation("查询所有品牌列表")
    @PostMapping("/getBrandListAll")
    public Result getBrandListAll() {
        return tbBrandService.getBrandListAll();
    }

    @ApiOperation("获取供应商列表")
    @PostMapping("/getApprListAll")
    public Result getApprListAll() {
        return tbApprService.getApprListAll();
    }

    /**
     * 批量删除
     */
    @ApiOperation("批量删除商品")
    @PostMapping("/deleteAllProd")
    public Result deleteAllProd(@RequestBody List<TbProd> tbProdList) {
        return tbProdService.deleteAllProd(tbProdList);
    }

    /**
     * 添加商品附件表
     */
    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody AttaVo attaVo){
        return tbProdService.addProdAtta(attaVo);
    }

    /**
     * 商品库存表
     */
    @PostMapping("/getProdInfoList")
   public  Result getProdInfoList(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getProdInfoList(pageInfoVo);
    }

}
